{extend name="common/layout"}

{block name="main"}
<div class="layui-card" style="display: none;">
	<div class="layui-card-body">
		<form id="webmanForm" class="layui-form" action="">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">文件名</label>
					<div class="layui-input-inline">
						<input type="text" name="name" placeholder="" class="layui-input">
					</div>
				</div>

				<div class="layui-inline" style="margin-left: 50px;">
					<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="webman-query">
						<i class="layui-icon layui-icon-search"></i>
						查询
					</button>
					<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="webman-refresh" >
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
					<button type="button" class="pear-btn pear-btn-md expand">
					</button>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="layui-card">
	<div class="layui-card-body">
		<table id="webman-table" lay-filter="webman-table"></table>
	</div>
</div>
{/block}

{block name="footer_script"}
<script>
	layui.use(['table', 'form', 'jquery', 'drawer', 'dropdown'], function() {
		let table = layui.table;
		let form = layui.form;
		let $ = layui.jquery;
		let drawer = layui.drawer;
		let dropdown = layui.dropdown;

		let cols = [
			[   {
				title: 'ID',
				field: 'id',
				align: 'center',
				width: 50
			},
				{
					title: '原始文件名',
					field: 'origin_name',
					align: 'center',
				},
				{
					title: '类型',
					field: 'mime_type',
					align: 'center',
				},
                {
					title: 'unique_id',
					field: 'unique_id',
					align: 'center',
				},
				{
					title: '后缀',
					field: 'extension',
					align: 'center',
				},
				{
					title: '大小',
					field: 'size',
					align: 'center',
				},
                {
					title: '访问地址',
					field: 'url',
					align: 'center',
				},
				{
					title: '创建时间',
					field: 'create_time',
					align: 'center',
				}
			]
		]

		table.render({
			elem: '#webman-table',
			url: '/admin/system/getUploadFile',
			page: true,
			limits: [10,30,100,500,1000,2000],
			cols: cols,
			skin: 'line',
			toolbar: '#webman-toolbar',
			response: {
				statusCode: 1
			},
			defaultToolbar: [{
				layEvent: 'refresh',
				icon: 'layui-icon-refresh',
			}, 'filter', 'print', 'exports'],
		});

		table.on('toolbar(webman-table)', function(obj) {
			if (obj.event === 'refresh') {
				window.refresh();
			}
		});

		form.on('submit(webman-query)', function(data) {
			table.reload('webman-table', {
				where: data.field
			})
			return false;
		});

		form.on('submit(webman-refresh)',function(data){
			//alert('123');
			parent.layui.admin.refreshThis()
			return false;
		});

		window.refresh = function(param) {
			table.reload('webman-table');
		}
	})
</script>
{/block}
